package tcards.android;

import models.PersonnelTcard;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;

public class PersFieldList extends LinearLayout {
	private GeneralFieldList mGeneralList;
	private TextField        mPosition;
	private TextField        mContactInfo;
	private PeopleFieldList  mPeopleList;
	
	public PersFieldList(Context context) {
		this(context, null, 0);
	}

	public PersFieldList(Context context, AttributeSet attrs) {
		this(context, attrs, 0);
	}

	public PersFieldList(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		LayoutInflater li = LayoutInflater.from(context);
		addView(li.inflate(R.layout.pers_field_list, this, false));
		
		mGeneralList = (GeneralFieldList) findViewById(R.id.persGeneralList);
		mPosition    = (TextField)        findViewById(R.id.positionField);
		mContactInfo = (TextField)        findViewById(R.id.persContactInfoField);
		mPeopleList  = (PeopleFieldList)  findViewById(R.id.persPeopleList);
	}
	
	public void setTcardFields(PersonnelTcard tcard) {
		mGeneralList.setTcardFields(tcard);
		tcard.setPosition(mPosition.getTextValue());
		tcard.setContactInfo(mContactInfo.getTextValue());
		mPeopleList.setTcardFields(tcard);
	}
	
	public void setListFields(PersonnelTcard tcard) {
		mGeneralList.setListFields(tcard);
		mPosition.setTextValue(tcard.getPosition());
		mContactInfo.setTextValue(tcard.getContactInfo());
		mPeopleList.setListFields(tcard);
	}
	
	public GeneralFieldList getGeneralList() {
		return mGeneralList;
	}
	
	public TextField getPosition() {
		return mPosition;
	}
	
	public TextField getContactInfo() {
		return mContactInfo;
	}
	
	public PeopleFieldList getPeopleList() {
		return mPeopleList;
	}
}